﻿#pragma once

#include "Ability/EditorAbilityModel.h"
#include "EditorObjectPropertyAbilityModel.m.h"

class REditorPropertyModel;
class RSceneNodeComponent;

RCLASS(ExtraHeader="Property/EditorPropertyModel.h")
class REditorObjectPropertyAbilityModel : public REditorAbilityModel
{
    ROBJECT

public: 
    virtual CString GetName() const override;
    void FirstTimeInitializeObject() override;   


    TDelegate<void> OnPropertyListChanged;
    TSharedObjectPtr<RObject> GetObject() const { return Object; }
    int64_t GetPropertiesNum() const { return Properties.Num(); }
    TSharedObjectPtr<REditorPropertyModel> GetProperty(int64_t Index) const { return Properties[Index]; }

    void AddComponent(TSubclassOf<RSceneNodeComponent> InComponentClass);
    void RemoveComponent(TSharedObjectPtr<RSceneNodeComponent> InComponent);
protected:

    RFIELD()
    TSharedObjectPtr<RObject> Object;

    RFUNCTION()
    void OnFocusedObjectChanged(TSharedObjectPtr<RObject> InObject);

    RFIELD()
    TVector<TSharedObjectPtr<REditorPropertyModel>> Properties;

    void UpdateProperties();
};